package com.topc.participant.api;

import cn.hutool.core.util.ObjectUtil;
import com.topc.base.api.CommonResult;
import com.topc.base.model.UserAuthDto;
import com.topc.participant.service.IAdminInfoService;
import com.topc.participant.util.SecurityUtil;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("管理员业务开放接口")
@Slf4j
@RestController
@RequestMapping("/open/admin")
public class AdminOpenController {

    @Autowired
    private IAdminInfoService adminInfoService;

    @GetMapping("/logout")
    public CommonResult<String> logOut(){
        UserAuthDto user = SecurityUtil.getUser();
        if (ObjectUtil.isNotEmpty(user)) adminInfoService.logout(user.getNumber());
        return CommonResult.success("退出成功");
    }

}
